/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chating;
import java.util.ArrayList;
/**
 *
 * @author Andi
 */
public class DataContainer {
    // attributes
    private ArrayList<Room> rooms;
    private ArrayList<User> users;

    // container
    public DataContainer(){
        this.rooms = new ArrayList<Room>();
        this.users = new ArrayList<User>();
    }

    // getter and setter
    /**
     * @return the rooms
     */
    public ArrayList<Room> getRooms() {
        return rooms;
    }

    /**
     * @param rooms the rooms to set
     */
    public void setRooms(ArrayList<Room> rooms) {
        this.rooms = rooms;
    }

    /**
     * @return the users
     */
    public ArrayList<User> getUsers() {
        return users;
    }

    /**
     * @param users the users to set
     */
    public void setUsers(ArrayList<User> users) {
        this.users = users;
    }

    public User getUserByName(String name){
        User u = new User();
        for(int i=0; i<this.users.size(); i++){
            if(this.users.get(i).getUserName().equalsIgnoreCase(name)){
                u = new User(this.users.get(i));
            }
        }
        return u;
    }

    public Room getRoomByName(String name){
        Room r = new Room();
        for(int i=0; i<this.rooms.size(); i++){
            if(this.rooms.get(i).getNameRoom().equalsIgnoreCase(name)){
                r = new Room(this.rooms.get(i));
            }
        }
        return r;
    }

    public void addRoom(Room r){
        this.rooms.add(r);
    }

    public void addUser(User u){
        this.users.add(u);
    }
}
